package com.hentica.app.component.photo;

import android.content.Context;
import android.view.WindowManager;

public class DpUtils {
    private static WindowManager windowManager;
    private static Context mContext;

    public DpUtils() {
    }

    public static void init(Context context) {
        windowManager = (WindowManager)context.getSystemService("window");
        mContext = context;
    }

    public static int dp2px(Context context, int dp) {
        if (context == null) {
            throw new IllegalStateException("context must not be null!");
        } else {
            return (int)(context.getResources().getDisplayMetrics().density * (float)dp + 0.5F);
        }
    }

    public static int dp2px(int dp) {
        return (int)(mContext.getResources().getDisplayMetrics().density * (float)dp + 0.5F);
    }

    public static int screenHeight() {
        int height = windowManager.getDefaultDisplay().getHeight();
        return height;
    }

    public static int screnWidth() {
        int width = windowManager.getDefaultDisplay().getWidth();
        return width;
    }
}

